package reflect.method;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        Class<Student> aClass = (Class<Student>)Class.forName("reflect.method.Student");
        //返回所有公共public修饰的方法数组，包含继承的
        Method[] methods = aClass.getMethods();
        for (Method method : methods) {
            System.out.println(method);
        }
        System.out.println("0.0.0.0.0..0.0.0.0.0.0.0.0.0.0.0.0.0.");
        //返回所有方法的方法数组，不包含继承的
        Method[] declaredMethods = aClass.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            System.out.println(declaredMethod);
        }
        System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        //返回单个方法   无参无返回值
        Method function1 = aClass.getMethod("function1");
        System.out.println(function1);
        System.out.println("122121111111111111111111111111111");
        //返回单个方法  有参无返回值
        Method function2 = aClass.getMethod("function2", String.class);
        System.out.println(function2);
        System.out.println("444444444444444444444444444444444");
        //返回单个方法  有参有返回值
        Method function4 = aClass.getMethod("function4", String.class);
        System.out.println(function4);
    }
}
